<template>
	<!-- 找回提现密码 -->
	<view>
		<view>
			<view class="edit">
				<view class="editPass flex">
					<text>手机号</text>
					<input type="text" disabled='true' v-model="mobile"/>
					<view class="vercodenull"></view>
				</view>
			</view>
			<view class="edit">
				<view class="editPass flex">
					<text>验证码</text>
					<input type="text" placeholder="请输入验证码" v-model="verCode"/>
					<view class="vercode" @click="fnGetVerCode()">{{codeText}}</view>
				</view>
			</view>
			<view class="editBtn flex-c" @click="fnFindWithdrawPassword()">
				<text>下一步</text>
			</view>
		</view>
	</view>
</template>

<script>
	const util = require('../../../common/util.js')
	export default {
		data() {
			return {
				mobile:'',
				verCode:'',
				flag:true,
				codeText:'验证码',
				token:uni.getStorageSync('token')
			};
		},
		onLoad(option) {
			this.mobile = option.mobile
		},
		methods:{
			fnGetVerCode(){
				if (util.isPhoneNo(this.mobile)) { //验证是手机号 获取验证码
					if (!this.flag) return
					var count = 60
					this.codeText = count+'s'
					var that = this
					var timer = setInterval(function() {
						that.flag = false
						count--
						that.codeText = count+'s'
						if (count <= 0) {
							clearInterval(timer)
							that.codeText = '验证码'
							that.flag = true
						}
					}, 1000)
					this.fnGetFindVerCode()
				} else {
					return
				}
			},
			// 获取验证码接口
			fnGetFindVerCode() {
				this.request({
					url: '/czb/User/sendSms',
					method: 'POST',
					data: {
						'type': 4,
						'token': this.token,
						'store_id': 1
					},
				}).then((ret) => {
					console.log(ret);
				})
			},
			fnFindWithdrawPassword(){
				if(!this.verCode) return uni.showToast({
					title:'请输入验证码',
					icon:'none'
				})
				this.request({
					url: '/czb/user/validateSms',
					method: 'POST',
					data: {
						'code': this.verCode,
						'token': this.token,
						'store_id': 1,
						'type':1
					},
				}).then((ret) => {
					console.log(ret);
					if(ret.code == 0){
						uni.navigateTo({
							url:'findPassword'
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		padding: 30rpx 0;
	}
	.edit{
		.editPass{
			height: 120rpx;
			background: #fff;
			padding: 0 20rpx;
			font-size: 28rpx;
			margin-bottom: 30rpx;
			align-items: center;
			text{
				flex: 1;
				font-size: 30rpx;
			}
			input{
				flex: 2.5;
				margin-right: 10rpx;
			}
		}
	}
	.editBtn{
		width: 710rpx;
		height: 90rpx;
		border-radius: 20rpx;
		background: linear-gradient(270deg, #F22F29, #FC6655);
		margin: 60rpx auto 20rpx;
		color: #fff;
		font-size: 30rpx;
	}
	.vercode{
		color: #fff;
		background: #F22F29;
		width: 120rpx;
		border-radius: 10rpx;
		padding: 20rpx;
		text-align: center;
	}
	.vercodenull{
		width: 160rpx;
	}
</style>
